package com.hzlj.position.locate.dao;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fz.common.base.converter.QueryWrapperConverterPlus;
import com.fz.common.base.dto.PageParamDTO;
import com.fz.common.base.dto.QueryPageResultDTO;
import com.hzlj.position.locate.common.dto.abnMissingJzryNotice.AbnMissingJzryNoticeQueryParamDTO;
import com.hzlj.position.locate.common.dto.abnMissingJzryNotice.AbnMissingJzryNoticeQueryResultDTO;
import com.hzlj.position.locate.common.model.AbnMissingJzryNotice;
import com.hzlj.position.locate.mapper.AbnMissingJzryNoticeMapper;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * 定位分析-疑似失联人员-通知(AbnMissingJzryNotice)表操作类
 *
 * @author makejava
 * @date 2024-06-25 14:40:44
 */
@Repository
public class AbnMissingJzryNoticeDao extends ServiceImpl<AbnMissingJzryNoticeMapper, AbnMissingJzryNotice> {
    @Resource
    private AbnMissingJzryNoticeMapper abnMissingJzryNoticeMapper;


    public AbnMissingJzryNoticeQueryResultDTO getByStep(String missingId, String step) {
        return QueryWrapperConverterPlus.of(abnMissingJzryNoticeMapper)
                .selectOne(AbnMissingJzryNoticeQueryResultDTO.class, null, null, q -> q
                        .eq(AbnMissingJzryNotice::getMissingId, missingId)
                        .eq(AbnMissingJzryNotice::getNoticeStep, step)
                );
    }


    public void updateNoticeTimeByStep(String missingId, String step, Date noticeTime) {
        LambdaUpdateWrapper<AbnMissingJzryNotice> updateWrapper = new UpdateWrapper<AbnMissingJzryNotice>().lambda()
                .set(AbnMissingJzryNotice::getNoticeTime, noticeTime)
                .eq(AbnMissingJzryNotice::getMissingId, missingId)
                .eq(AbnMissingJzryNotice::getNoticeStep, step);
        this.update(updateWrapper);
    }

    /**
     * 查询列表：不分页
     */
    public List<AbnMissingJzryNoticeQueryResultDTO> listAbnMissingJzryNotice(AbnMissingJzryNoticeQueryParamDTO dto) {
        return QueryWrapperConverterPlus.of(abnMissingJzryNoticeMapper)
                .list(AbnMissingJzryNoticeQueryResultDTO.class, dto);
    }

    /**
     * 查询列表：分页
     */
    public QueryPageResultDTO<AbnMissingJzryNoticeQueryResultDTO> pageAbnMissingJzryNotice(AbnMissingJzryNoticeQueryParamDTO dto, PageParamDTO page) {
        return QueryWrapperConverterPlus.of(abnMissingJzryNoticeMapper)
                .page(AbnMissingJzryNoticeQueryResultDTO.class, dto, page);
    }


}

